package main

import (
	"context"
	"fmt"
	"github.com/sirupsen/logrus"
	clientv3 "go.etcd.io/etcd/client/v3"
	"time"
)

func main() {
	cli, err := clientv3.New(clientv3.Config{
		Endpoints:   []string{":2379"},
		DialTimeout: time.Second * 5,
	})
	if err != nil {
		logrus.Fatalln(err)
	}
	defer cli.Close()

	watchChan := cli.Watch(context.Background(), "collect_log")

	for wrsp := range watchChan {
		for _, ev := range wrsp.Events {
			fmt.Printf("Type:%v Key:%s Value:%s\n", ev.Type, ev.Kv.Key, ev.Kv.Value)
		}
	}
}
